package com.leyou.privilege.web;

import com.leyou.privilege.dto.ApplicationDTO;
import com.leyou.privilege.service.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: wangzibeng
 * Date: 2019/5/16 0016
 * Time: 11:57
 */

@RestController
@RequestMapping("app")
public class ApplicationController {
    @Autowired
    ApplicationService applicationService;

    @PostMapping
    public ResponseEntity<Void> saveApplication(ApplicationDTO applicationDTO) {
        applicationService.saveApplication(applicationDTO);
        return ResponseEntity.status(HttpStatus.CREATED).build();
    }

    @GetMapping("query")
    public ResponseEntity<ApplicationDTO> queryApplicationByIdAndSecret(@RequestParam("id") Long id, @RequestParam("secret") String secret) {
        return ResponseEntity.ok(applicationService.queryApplicationByIdAndSecret(id, secret));
    }

}
